package com.qianfeng.missfood.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.qianfeng.missfood.BaseApp;
import com.qianfeng.missfood.R;
import com.qianfeng.missfood.bean.User;

public class MyMsgActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_msg);

        initView();

    }

    private void initView() {

        int[] resId = new int[]{R.id.myMsgNickName, R.id.myMsgSex, R.id.myMsgAddress, R.id.myMsgPhone, R.id.myMsgPsw};
        String[] titleStr = new String[]{"昵称", "性别", "收货地址", "登录手机号", "登录密码"};
        User user = BaseApp.getInstance().getUser();
        String[] contentStr = new String[]{user.getNickName(), user.getSex(), "", user.getPhone(), ""};
        int len = resId.length;
        for (int i = 0; i < len; i++) {

            View view = findViewById(resId[i]);
            TextView title = (TextView) view.findViewById(R.id.myMsgTitle);
            TextView content = (TextView) view.findViewById(R.id.myMsgContent);
            title.setText(titleStr[i]);
            content.setText(contentStr[i]);

        }

        Button exitLogin = (Button) findViewById(R.id.exitLogin);
        exitLogin.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.exitLogin:

                BaseApp.getInstance().setLoginState(false);
                Intent intent = new Intent(this, GuideActivity.class);
                startActivity(intent);
                finish();
                break;

            default:

                break;


        }

    }
}
